import request from '@/utils/request'

export function login(data: object) {
  return request({
    url: 'user/login',
    method: 'post',
    data: data,
    timeout: 10000
  })
}

export function logout() {
  return request({
    url: 'user/logout',
    method: 'delete',
    data: null
  })
}

export function register(data: object) {
  return request({
    url: 'user/register',
    method: 'post',
    data: data
  })
}

export function resetPassword(data: object) {
  return request({
    url: '/user/resetPassword',
    method: 'put',
    data: data
  })
}

export function getUserInfo() {
  return request({
    url: '/user/getUserInfo',
    method: 'get'
  })
}

export function saveUserInfo(data: object) {
  return request({
    url: '/user/saveUserInfo',
    method: 'post',
    data: data
  })
}

export function isLogin() {
  return request({
    url: '/user/isLogin',
    method: 'get'
  })
}

// 查询用户信息列表
export function getUserList(data: object) {
  return request({
    url: '/user/getUserList',
    method: 'post',
    data: data
  })
}

// 查询用户信息详细
export function getUserById(studentId: string) {
  return request({
    url: '/user/getUserById/' + studentId,
    method: 'get'
  })
}

// 新增用户信息
export function addUserByAdmin(data:object) {
  return request({
    url: '/user/addUserByAdmin',
    method: 'post',
    data: data
  })
}

// 修改用户信息
export function updateUserByAdmin(data:object) {
  return request({
    url: '/user/updateUserByAdmin',
    method: 'put',
    data: data
  })
}

// 删除用户信息
export function deleteUserByAdmin(studentId:string) {
  return request({
    url: '/user/deleteUserByAdmin/' + studentId,
    method: 'delete'
  })
}

// 修改密码
export function updatePassword(data: object) {
  return request({
    url: '/user/changePassword',
    method: 'post',
    data: data
  })
}
